<!-- 发布动态 -->
<template>
	<div>
		<text class="form-title">动态信息</text>
		<dynForm :formInline="formInline" :formItem="formItem" :btnText="btnText" @changePicker="changePicker" @onSubmit='onSubmit'></dynForm>
	</div>

</template>

<script>
	import dynForm from "../../components/current/vForm.vue";

	export default {
		components: {
			dynForm
		},
		data() {
			return {
				//表格参数
				formItem: [{
						type: 'picker',
						pickerType: '',
						label: "基地名称",
						placeholder: "请选择基地名称",
						array: ['第一个', '第二个', '第三个'],
						index: "",
						clumn: 'name'
					},
					{
						type: 'input',
						label: "动态标题",
						placeholder: "请输入动态标题",
						clumn: 'title'
					},
					{
						type: 'radio',
						label: "动态类型",
						options: [{
							index: '1',
							value: '1',
							text: '生长动态',
							checked: 'checked'
						}, {
							index: '2',
							value: '2',
							text: '其他动态',
						}],
						clumn: 'type'
					},
					{
						type: 'uploadFile',
						label:'图片上传',
						labelPosition:'top',
						fileType:'image',
						clumn: 'imgArr'
					},
					{
						type: 'uploadFile',
						label:'视频上传',
						labelPosition:'top',
						fileType:'video',
						clumn: 'videoSrc'
					},
					{
						type: 'textarea',
						placeholder: "请输入动态内容",
						clumn: 'detailInfo'
					}
				],
				//表单字段数据
				formInline: {
					name: "",
					title: "",
					type: "",
					imgArr: [],
					videoSrc: [],
					detailInfo: "",
				},
				btnText: '发布'
			}
		},

		methods: {
			// 选择器发生改变时
			changePicker(i, clumn, value) {
				// 普通选择器赋值
				if (this.formItem[i].pickerType == '' || this.formItem[i].pickerType == 'selector') {
					this.formInline[clumn] = this.formItem[i].array[value];
					return
				}
				//时间选择器赋值
				if (this.formItem[i].pickerType == 'date') {
					this.formInline[clumn] = value;
					return
				}
			},

			//表单按钮提交方法
			onSubmit: function() {
				console.log("addDy")
				console.log(this.formInline)
			},
		}
	}
</script>

<style>
	.form-title {
		padding: 0 5%;
		color: rgb(136, 136, 136);
		line-height: 60rpx;
	}
</style>
